home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 November: Tool Chest / Dev.CD Nov 94.toast / Sample Code / Snippets / Development Tools & Languages / DTSCPlusLibrary / Sources / MemoryClass.h < prev    next >
Encoding:
Text File  |  1993-01-14  |  2.8 KB  |  95 lines  |  [TEXT/MPS ]

  1. /* _________________________________________________________________________________________________________ //
  2.   Copyright © 1993 Apple Computer, Inc. All rights reserved.
  3.   Macintosh Developer Technical Support.C++ Macintosh Toolbox Framework.
  4.   Programmer: Kent Sandvik
  5.   Date: 1/2/93
  6.   Revision comments are at the end of this file.
  7.   ---
  8.   TMemory is a simple object checks heap and stack values, as well as changes them.
  9.   TMemoryClass.h contains the TMemory class definitions. 
  10.   _________________________________________________________________________________________________________ */
  11.  
  12. // Declare label for this header file
  13. #ifndef _MEMORYCLASS_
  14. #define _MEMORYCLASS_
  15.  
  16. #ifndef _DTSCPLUSLIBRARY_
  17. #include "DTSCPlusLibrary.h"
  18. #endif
  19.  
  20. // TOOLBOX INCLUDES
  21. #ifndef __MEMORY__
  22. #include <Memory.h>
  23. #endif
  24.  
  25. #ifndef __RESOURCES__
  26. #include <Resources.h>
  27. #endif
  28.  
  29. #ifndef __TYPES__
  30. #include <Types.h>
  31. #endif
  32.  
  33. // GLOBAL DEFINITIONS
  34. const OSType kStackResource = 'stak';            // definition of our resource for defining stack size
  35.  
  36.  
  37. // _________________________________________________________________________________________________________ //
  38. //    TMemory Class Interface.
  39. class TMemory
  40. // TMemory is a simple memory utility class that keeps track of size of the stack and heap, and could
  41. // be used to manipulate the memory sizes.
  42. {
  43. public:
  44.     // TYPEDEFS AND ENUMS
  45.     enum EConstants                                // constants used in the TMemory class
  46.     {
  47.         kNoMinHeap = 0, kNoMinStack = 0
  48.     };
  49.  
  50.     // CONSTRUCTORS AND DESTRUCTORS
  51.     TMemory(const long minHeap = kNoMinHeap,
  52.             // default constructor
  53.             // default constructor
  54.             const long minStack = kNoMinStack);
  55.     virtual~ TMemory();                            // default destructor
  56.  
  57.     // MAIN INTERFACE
  58.     virtual long GetStackSize();                // get size of stack
  59.     virtual Boolean SetStackSize(const long stackValue);// set new stack size
  60.     virtual Boolean SetStackSizeFromResources();// set stack sizes based on resource information
  61.     virtual Boolean IncreaseStackSize(const long stackValue);// increase the current stack size
  62.     virtual Boolean CheckStackSize();            // check if selected min stack size is OK
  63.     virtual Boolean CheckHeapSize();            // check if selected min heap size is OK
  64.  
  65.     virtual long GetHeapSize();                    // get size of heap
  66.  
  67.     // FIELDS
  68. protected:
  69.     long fMinHeap;                                // minimum heap size
  70.     long fMinStack;                                // minimum stack size
  71.     OSErr fError;                                // latest error
  72.  
  73.     // PRIVATE STRUCTURES
  74. private:
  75.     struct StackResource                        // for the kStackResource resource mapping
  76.     {
  77.         long stackVal;                            // the new stack size
  78.     };
  79.  
  80.  
  81.     typedef StackResource* StackValuePtr;        // typecasted for handy re-use
  82.     typedef StackResource** StackValueHandle;
  83. };
  84.  
  85.  
  86. #endif
  87.  
  88. // _________________________________________________________________________________________________________ //
  89.  
  90. /*    Change History (most recent last):
  91.   No        Init.    Date        Comment
  92.   1            khs        1/2/93        New file
  93.   2            khs        1/3/93        Cleanup
  94. */
  95.